package com.dyz.LeetCodeforSwordFingerOffer;

/**
 * @author: daiyizheng
 * @date: 2021/7/9 0:19
 * @description:
 */
public class ConstructArr65 {
    public int[] constructArr(int[] a) {
        if(a==null||a.length==0){return new int[]{};}
        //前缀乘积
        int[] b1 = new int[a.length];
        b1[0] = 1;
        for(int i=1;i<a.length;i++){
            b1[i] = b1[i-1]*a[i-1];
        }
        //后缀乘积
        int temp = 1;
        for(int j=a.length-2; j>=0;j--){
            temp *=a[j+1];
            b1[j]*=temp;
        }

        return b1;
    }
}
